﻿
Public Class escape
    Public Const functionName As String = "esc"

    Public Shared Sub register(ByVal inlineScript As inlineScript)
        assert(Not inlineScript Is Nothing, "inlineScript is nothing.")

        inlineScript.addscript("escape", "function " + functionName + "(i){return escape(i);}")
    End Sub

    Public Shared Function invoke(ByVal inlineScript As inlineScript, ByVal input As String, _
                                  Optional ByRef actionTarget As String = Nothing) As String
        If Not inlineScript Is Nothing Then
            register(inlineScript)
        End If

        actionTarget += functionName + "(" + input + ")"
        Return actionTarget
    End Function
End Class

Public Class unescape
    Public Const functionName As String = "uec"

    Public Shared Sub register(ByVal inlineScript As inlineScript)
        assert(Not inlineScript Is Nothing, "inlineScript is nothing.")

        inlineScript.addscript("unescape", "function " + functionName + "(i){return unescape(i);}")
    End Sub

    Public Shared Function invoke(ByVal inlineScript As inlineScript, ByVal input As String, _
                                  Optional ByRef actionTarget As String = Nothing) As String
        If Not inlineScript Is Nothing Then
            register(inlineScript)
        End If

        actionTarget += functionName + "(" + input + ")"
        Return actionTarget
    End Function
End Class

Public Class encodeURI
    Public Const functionName As String = "ecu"

    Public Shared Sub register(ByVal inlineScript As inlineScript)
        assert(Not inlineScript Is Nothing, "inlineScript is nothing.")

        inlineScript.addscript("encodeURI", "function " + functionName + "(i){return encodeURI(i);}")
    End Sub

    Public Shared Function invoke(ByVal inlineScript As inlineScript, ByVal input As String, _
                                  Optional ByRef actionTarget As String = Nothing) As String
        If Not inlineScript Is Nothing Then
            register(inlineScript)
        End If

        actionTarget += functionName + "(" + input + ")"
        Return actionTarget
    End Function
End Class

Public Class encodeURIComponent
    Public Const functionName As String = "ecuc"

    Public Shared Sub register(ByVal inlineScript As inlineScript)
        assert(Not inlineScript Is Nothing, "inlineScript is nothing.")

        inlineScript.addscript("encodeURIComponent", "function " + functionName + "(i){return encodeURIComponent(i);}")
    End Sub

    Public Shared Function invoke(ByVal inlineScript As inlineScript, ByVal input As String, _
                                  Optional ByRef actionTarget As String = Nothing) As String
        If Not inlineScript Is Nothing Then
            register(inlineScript)
        End If

        actionTarget += functionName + "(" + input + ")"
        Return actionTarget
    End Function
End Class

Public Class decodeURI
    Public Const functionName As String = "dcu"

    Public Shared Sub register(ByVal inlineScript As inlineScript)
        assert(Not inlineScript Is Nothing, "inlineScript is nothing.")

        inlineScript.addscript("decodeURI", "function " + functionName + "(i){return decodeURI(i);}")
    End Sub

    Public Shared Function invoke(ByVal inlineScript As inlineScript, ByVal input As String, _
                                  Optional ByRef actionTarget As String = Nothing) As String
        If Not inlineScript Is Nothing Then
            register(inlineScript)
        End If

        actionTarget += functionName + "(" + input + ")"
        Return actionTarget
    End Function
End Class

Public Class decodeURIComponent
    Public Const functionName As String = "dcuc"

    Public Shared Sub register(ByVal inlineScript As inlineScript)
        assert(Not inlineScript Is Nothing, "inlineScript is nothing.")

        inlineScript.addscript("decodeURIComponent", "function " + functionName + "(i){return decodeURIComponent(i);}")
    End Sub

    Public Shared Function invoke(ByVal inlineScript As inlineScript, ByVal input As String, _
                                  Optional ByRef actionTarget As String = Nothing) As String
        If Not inlineScript Is Nothing Then
            register(inlineScript)
        End If

        actionTarget += functionName + "(" + input + ")"
        Return actionTarget
    End Function
End Class

Public Class htmlDecode
    Public Const functionName As String = "hdc"

    Public Shared Sub register(ByVal inlineScript As inlineScript)
        assert(Not inlineScript Is Nothing, "inlineScript is nothing.")

        inlineScript.addscript("htmlDecode", "function " + functionName + "(i){" + _
                               var.invoke("t", createElement.invoke(inlineScript, "'div'")) + ";" + _
                               "t.innerHTML=i;" + _
                               "return " + questioncolon.invoke("t.innerText", "t.innerText", "t.textContent") + _
                               ";}")
    End Sub

    Public Shared Function invoke(ByVal inlineScript As inlineScript, ByVal input As String, _
                                  Optional ByRef actionTarget As String = Nothing) As String
        If Not inlineScript Is Nothing Then
            register(inlineScript)
        End If

        actionTarget += functionName + "(" + input + ")"
        Return actionTarget
    End Function
End Class